import request from '@/config/axios'

export interface MgmtNcrVO {
  id: number
  inspectionTaskCode: string
  ncrCode: string
  partCode: string
  partName: string
  defectiveQuantity: number
  drawingCode: string
  productCode: string
  dictConfigQualityInspectType: number
  dictResponsibleDept: number
  responsiblePerson: string
  problemDescription: string
  problemAttachmentId: string
  problemAttachmentName: string
  problemAttachmentPath: string
  dictNcrStatus: number
  dictNcrProcessResult: number
  customerName: string
  specification: string
  unit: string
  dictDiscoveryProcess: number
  supplierName: string
  dictMaterialType: number
  causeAnalysis: string
  causeAnalysisAttachmentId: string
  causeAnalysisAttachmentName: string
  causeAnalysisAttachmentPath: string
  creatorName: string
  productName: string
}

// 查询质量管理-品质管理-NCR列表列表
export const getMgmtNcrPage = async (params) => {
  return await request.get({ url: `/quality/mgmt-ncr/page`, params })
}

// 查询质量管理-品质管理-NCR列表详情
export const getMgmtNcr = async (id: number) => {
  return await request.get({ url: `/quality/mgmt-ncr/get?id=` + id })
}

// 新增质量管理-品质管理-NCR列表
export const createMgmtNcr = async (data: MgmtNcrVO) => {
  return await request.post({ url: `/quality/mgmt-ncr/create`, data })
}

// 修改质量管理-品质管理-NCR列表
export const updateMgmtNcr = async (data: MgmtNcrVO) => {
  return await request.put({ url: `/quality/mgmt-ncr/update`, data })
}

// 删除质量管理-品质管理-NCR列表
export const deleteMgmtNcr = async (id: number) => {
  return await request.delete({ url: `/quality/mgmt-ncr/delete?id=` + id })
}

// 导出质量管理-品质管理-NCR列表 Excel
export const exportMgmtNcr = async (data) => {
  return await request.download({ url: `/quality/mgmt-ncr/export-excel`, data })
}

//供应商列表
export const getSupplierList = async (params) => {
  return await request.get({ url: `/config/srm-supplier/list`, params })
}

//责任人列表
export const getResponsiblePersonList = async (params) => {
  return await request.get({ url: `/system/user/list-all-simple-other`, params })
}

// 编辑中
export const updateEditing = async (data: MgmtNcrVO) => {
  return await request.put({ url: `/quality/mgmt-ncr/updateEditing`, data })
}

//待处理
export const updatePending = async (data: MgmtNcrVO) => {
  return await request.put({ url: `/quality/mgmt-ncr/updatePending`, data })
}

//已处理
export const updateProcessed = async (data: MgmtNcrVO) => {
  return await request.put({ url: `/quality/mgmt-ncr/updateProcessed`, data })
}

// 查询配置中心-部门信息列表(无分页,关键字查询)
export const getDeptList = async (params) => {
  return await request.get({ url: `/config/org-dept-archives/list-all-simple`,params})
}